package com.dingli.shop.controller;

import com.dingli.shop.po.ReportVO;
import com.dingli.shop.vo.JsonVo;
import com.dingli.shop.vo.Meta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/reports/type")
@RestController
@CrossOrigin
public class ReportController {

    @Autowired
    private ReportBiz reportBiz;

    @GetMapping("/1")
    public JsonVo report() {
        ReportVO reportVO = reportBiz.findReport();

        Meta meta = new Meta();
        if (reportVO == null) {
            meta.setMsg("获取报表失败");
            meta.setStatus(400);
        } else {
            meta.setMsg("获取报表成功");
            meta.setStatus(200);
        }
        JsonVo jsonVo = new JsonVo();
        jsonVo.setData(reportVO);
        jsonVo.setMeta(meta);
        return jsonVo;
    }

}
